<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 三个水瓶互倒
    var arr = [1, 2, 3, 4, 5, 7, 8, 9, 1, 2, 34, 5, 7, 9, 0, 1]
    function AsSs(arr) {
        for (let index = 0; index < arr.length - 1; index++) {
            for (let i = 0; i < arr.length - index - 1; i++) {
                if (arr[i] > arr[i + 1]) {
                    let xc = arr[i + 1]
                    arr[i + 1] = arr[i]
                    arr[i] = xc
                }
            }
        }
        return arr
        // console.log(arr);
    }
    console.log(AsSs(arr));



    // 解构赋值
    var aff= [1, 2, 3, 4, 5, 7, 8, 9, 1, 2, 34, 5, 7, 9, 0, 1,23]
    function AsS(aff) {
        for (let index = 0; index < aff.length - 1; index++) {
            for (let i = 0; i < aff.length - 1; i++) {
                if (aff[i] > aff[i + 1]) {
                    [aff[i+1],aff[i]]=[aff[i],aff[i+1]]
                }
            }
        }
        return aff
        // console.log(arr);
    }
    console.log(AsS(aff));
</script>

</html>